Method and apparatus for culling

ABSTRACT

The present invention is to provide a culling method, used in the computer graphics systems, for determining the visibility of two adjacent polygons of a polyhedron at the same time. It also provides a culling apparatus, which uses the method to execute the culling test. The culling apparatus comprises one multiplier, three multiplexers, two registers, one adder/subtractor, and a controller with a set of instructions to control the whole procedure.

BACKGROUND OF THE INVENTION

A. Field of the Invention

This invention relates generally to a method and an apparatus for culling and, more particularly, to a method and an apparatus for accelerating culling tests in computer graphics systems.

B. Description of the Related Art

A computer graphics system is commonly used to display three-dimensional representations of an object on a two-dimensional display screen. In a typical computer graphics system, an object to be rendered is divided into a plurality of graphics primitives. The graphics primitives are basic components of a graphics picture and may be defined by geometries of a point, line, vector, or polygon, such as a triangle. The graphics primitives are fed through a graphics pipeline where various types of processing occur and are then rendered on a display.

Culling, also called backface elimination, is an operation that compares the orientation of polygons in a polyhedron with the viewpoint or center of projection, and removes those polygons that cannot be seen. On average, half of the polygons in a polyhedron are backfacing and the advantage of this process is by using a simple test to remove these polygons. The test for visibility is straightforward and is best carried out in view space. We calculate the outward normal of a polygon and examine the sign of the dot product of this normal vector and the vector from the center of projection, as illustrated in FIG. 1.

As shown in FIG. 1 are the outward normal vector of a polygon N_(p), and the ‘line of sight’ vector N from the center of the face to the viewpoint. Based on these two vectors, the visibility of a polygon is defined as:

 Visibility=N _(p) ·N>0

Where:

N_(p) is the polygon normal

N is the ‘line of sight’ vector

In order to determine whether a polygon is visible on a two-dimensional flat screen, select three points V₁, V₂, and V₃ from the polygon where the V₁ is the center point, V₂ and V₃ are any points on the surface which satisfy the condition that V₁, V₂, and V₃ are not on the same line, and (V₁, V₂, V₃) is distributed counterclockwise.

From the visibility test:

Visibility=N _(p) ·N[(V ₂ −V ₁)×(V ₃ −V ₁)]·(V ₁ −V ₀)>0

Where:

V₀ is the viewpoint (0, 0, 0), and

V₁, V₂, and V₃ are the selected vertices (x₁, y₁, z₁), (x₂, y₂, z₂), and (x₃, y₃, z₃) for a triangle.

The calculation for the visibility test is: ${Visibility} = \left| \begin{matrix} x_{1} & y_{1} & z_{1} \\ x_{2} & y_{2} & z_{2} \\ x_{3} & y_{3} & z_{3} \end{matrix} \middle| {> 0} \right.$

Although the equation for the culling test may seem to be relatively simple and straightforward, it takes twelve multiplication processes and five addition/subtraction processes to complete the whole calculation to test the visibility for one triangle. For two triangles, hence, it takes 24 multiplications and 10 addition/subtractions. Not only is the calculation process unwieldy but also time-consuming.

SUMMARY OF THE INVENTION

In view of these problems, the object of the present invention is to provide a method and an apparatus for use in computer graphics system which can render and display graphics primitives faster.

In one aspect of the present invention, a method is provided for determining, at the same time, whether two adjacent polygons of a polyhedron are visible on a 2-dimensional visual display unit. The test can be done more easily and rapidly. It lends itself to rapid real-time culling and eliminates surfaces certain to be not visible at the observer's viewpoint.

Another aspect of the present invention is to provide an apparatus to execute the culling test described above. The culling apparatus comprises one multiplier, three multiplexers, two registers, one adder/subtractor, and a computer program with a set of commands controlling the flow and process of data. The instruction commands may be installed in ROM to be used in the computer graphic systems in order to compute and control all data inputs and outputs of culling test.

The benefits of this invention will become evident as the present invention is described more fully below.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a geometric description of the culling operation.

FIG. 2 illustrates two adjacent triangles, according to one aspect of the present invention, sharing two vertices and one common side.

FIG. 3 is a schematic diagram illustrating the computation of culling tests for two adjacent triangles.

FIG. 4 is a block diagram of the culling test circuit of one preferred embodiment of the present invention.

TABLE 1 is a program for the culling test of two adjacent triangles according to one aspect of the present invention.

TABLE 2 is a step by step algorithm for the program shown in TABLE 1.

TABLE 3 is a program for the culling test which uses two multipliers and one adder according to one aspect of the present invention.

DETAILED DESCRIPTION OF PREFERRED EMBODIMENTS

As shown in FIG. 2, the two adjacent triangles, assumed not to be on the same plane of a 3-dimensional object, share two vertices. The present invention takes two adjacent triangles to perform the culling test synchronously, in order to save computation time and costs. If the selected triangles Δ₁₂₃ and Δ₄₂₃ of two adjacent polygons comprise four vertices {V₁, V₂, V₃, V₄}, the culling test of the present invention for Δ123 and Δ423 produce two outcomes. The calculation process is described below. $\Delta_{123} = {\left| \quad \begin{matrix} x_{1} & y_{1} & z_{1} \\ x_{2} & y_{2} & z_{2} \\ x_{3} & y_{3} & z_{3} \end{matrix} \right| = \quad {\left. x_{1} \middle| \quad \begin{matrix} y_{2} & z_{2} \\ y_{3} & z_{3} \end{matrix} \middle| \quad {+ y_{1}} \middle| \quad \begin{matrix} z_{2} & x_{2} \\ z_{3} & x_{3} \end{matrix} \middle| \quad {+ z_{1}} \middle| \quad \begin{matrix} x_{2} & y_{2} \\ x_{3} & y_{3} \end{matrix} \middle| \Delta_{423} \right. = {\left| \begin{matrix} x_{4} & y_{4} & z_{4} \\ x_{2} & y_{2} & z_{2} \\ x_{3} & y_{3} & z_{3} \end{matrix} \right| = \left. x_{4} \middle| \begin{matrix} y_{2} & z_{2} \\ y_{3} & z_{3} \end{matrix} \middle| {+ y_{4}} \middle| \begin{matrix} z_{2} & x_{2} \\ z_{3} & x_{3} \end{matrix} \middle| {+ z_{4}} \middle| \begin{matrix} x_{2} & y_{2} \\ x_{3} & y_{3} \end{matrix} \right|}}}$

From the two equations above, Δ123 and Δ423 have three common terms: $\left| \quad \begin{matrix} y_{2} & z_{2} \\ y_{3} & z_{3} \end{matrix} \right|\quad,\left| \quad \begin{matrix} z_{2} & x_{2} \\ z_{3} & x_{3} \end{matrix} \right|\quad,\left. {and}\quad \middle| \quad \begin{matrix} x_{2} & y_{2} \\ x_{3} & y_{3} \end{matrix} \right|,$

denoted by S₅, S₇ and S₉ respectively. By calculating these common terms before generating two test outcomes for the adjacent triangles, the present invention utilizes the present method and saves the computation time of culling test.

With reference to FIG. 2, the coordinates of the common vertices for Δ₁₂₃ and Δ₄₂₃ are V₂(x₂, y₂, z₂) and V₃(x₃, y₃, z₃), and side {overscore (V₂V₃)} is the common side for both triangles. Calculations for all embodiments described below are based on these coordinators as shown in FIG. 2.

FIG. 3 is one embodiment of the present invention. The architecture of the embodiment could provide two test outcomes simultaneously. The circuit is designed to compute common terms first then generate the outcomes.

From the calculation algorithms, the first step of the culling test is to compute the 6 terms: (y₂*z₃), (z₂*y₃), (z₂*x₃), (x₂*z₃), (x₂*y₃), and (y₂*x₃), and results are denoted by P₁, P₂, P₃, P₄, P₅, and P₆ respectively.

Secondly, compute the result of the 3 common terms (P₁−P₂), (P₃−P₄), and (P₅−P₆), results are denoted by S₅, S₇, and S₉ respectively.

Thirdly, bring in the third vertex of each triangle to the computation. Results for (x₁*S₅), (x₄*S₅), (y₁*S₇), (y₄*S₇), (z₁*S₉) and (z₄*S₉) are denoted by P₈, P₉, P₁₀, P₁₁, P₁₂ and P₁₃ respectively.

In mathematical expressions: $\Delta_{123} = \quad \left. x_{1} \middle| \quad \begin{matrix} y_{2} & z_{2} \\ y_{3} & z_{3} \end{matrix} \middle| \quad {+ y_{1}} \middle| \quad \begin{matrix} z_{2} & x_{2} \\ z_{3} & x_{3} \end{matrix} \middle| \quad {+ z_{1}} \middle| \quad \begin{matrix} x_{2} & y_{2} \\ x_{3} & y_{3} \end{matrix} \middle| \begin{matrix} {\Delta_{123} = {{x_{1}\left( {{y_{2}z_{3}} - {z_{2}y_{3}}} \right)} + {y_{1}\left( {{z_{2}x_{3}} - {x_{2}z_{3}}} \right)} + {z_{1}\left( {{x_{2}y_{3}} - {y_{2}x_{3}}} \right)}}} \\ {= {{x_{1}\left( {P_{1} - P_{2}} \right)} + {y_{1}\left( {P_{3} - P_{4}} \right)} + {z_{1}\left( {P_{5} - P_{6}} \right)}}} \\ {= {{x_{1}*S_{5}} + {y_{1}*S_{7}} + {z_{1}*S_{9}}}} \\ {= {P_{8} + P_{10} + P_{12}}} \end{matrix} \right.$ $\Delta_{423} = \quad \left. x_{4} \middle| \quad \begin{matrix} y_{2} & z_{2} \\ y_{3} & z_{3} \end{matrix} \middle| \quad {+ y_{4}} \middle| \quad \begin{matrix} z_{2} & x_{2} \\ z_{3} & x_{3} \end{matrix} \middle| \quad {+ z_{4}} \middle| \quad \begin{matrix} x_{2} & y_{2} \\ x_{3} & y_{3} \end{matrix} \middle| \begin{matrix} {\Delta_{423} = {{x_{4}\left( {{y_{2}z_{3}} - {z_{2}y_{3}}} \right)} + {y_{4}\left( {{z_{2}x_{3}} - {x_{2}z_{3}}} \right)} + {z_{4}\left( {{x_{2}y_{3}} - {y_{2}x_{3}}} \right)}}} \\ {= {{x_{4}\left( {P_{1} - P_{2}} \right)} + {y_{4}\left( {P_{3} - P_{4}} \right)} + {z_{4}\left( {P_{5} - P_{6}} \right)}}} \\ {= {{x_{4}*S_{5}} + {y_{4}*S_{7}} + {z_{4}*S_{9}}}} \\ {= {P_{9} + P_{11} + P_{13}}} \end{matrix} \right.$

Because computer can execute only one task at a time, it adds up two terms of the equations first, before adding the third ones to obtain the culling outcome. Thus: $\begin{matrix} {\Delta_{123} = {P_{8} + P_{10} + P_{12}}} \\ {= {\left( {P_{8} + P_{10}} \right) + P_{12}}} \\ {= {S_{13} + P_{12}}} \end{matrix}$ $\begin{matrix} {\Delta_{423} = {P_{9} + P_{11} + P_{13}}} \\ {= {\left( {P_{9} + P_{11}} \right) + P_{13}}} \\ {= {S_{14} + P_{13}}} \end{matrix}$

If the culling test for Δ₁₂₃=S₁₃+P₁₂ is greater than zero, the polygon where Δ₁₂₃ is selected from is visible; on the other hand, if the test outcome for Δ₁₂₃ is equal to or less than zero, the polygon is not visible. Likewise, if the test outcome for Δ₄₂₃ is greater than zero, the polygon is visible; if the test outcome is not equal to zero, the polygon is not visible.

Suppose the pipeline depths of all adders and multipliers used are equal to 3. With enough number of adders and multipliers, the five calculation steps of culling test for both Δ₁₂₃ and Δ₄₂₃, as shown in FIG. 3, can be completed within 15 cycles to obtain the outcomes.

Shown in FIG. 4 is an aspect of the culling test circuit for the present invention. In this embodiment, a controller 410 is used to control the culling test circuit. The controller 410 controls the data input order to the first multiplexer 421 and the multiplier 430, and data selections of the three multiplexers 421, 422, and 423. The culling test circuit consists of one multiplier, one adder/subtractor, two registers, and three multiplexers. The multiplier 430 receives two input data at beginning of each cycle for the computation, and the adder/subtractor 450 generates one output data at the end of each cycle. The whole computation process takes about 20 cycles to test the visibility of two adjacent planes of a 3-dimensional object.

Specifically speaking, the first multiplexer 421 has two receiving terminals where the first receiving terminal receives first primitive data from the system controller 410 and is sent to the second receiving terminal of the multiplier 430. The multiplier 430 has two receiving terminals where the first input terminal receives second primitive data from the system controller 410, and the second input terminal receives the output signal of the first multiplexer 421. The first register (R) 441 is used to store data received from the multiplier 430. The second register is used to store data received from said multiplier 430 as well. The second multiplexer 422 has two receiving terminals where the first terminal receives signals from the multiplier 430 and the third multiplexer 423 also has two receiving terminals receiving signals from the first and the second registers 441 and 442. The adder receives two primitives data from the second and third multiplexer 422 and 423, adds to or subtracts from the third multiplexer 423 the primitive data values stored in the second multiplexer 422. The outcome is then feedback to the first and the second multiplexers 421 and 422 until the whole procedure is completed.

Suppose the pipeline depths for both the multiplier 430 and the adder/subtractor 450 are 3, it means that if a computation starts at cycle K, the result of that computation will be obtained at cycle (K+3). One of the programs for the circuit to compute culling test is illustrated in TABLE 1. Take TABLE 1 as an example. A statement “P₁=y₂*z₃” at cycle 1 means that the computation of y₂ multiplies by z₃ is commenced at cycle 1. The controller 410 starts to feed the first primitive data z₃ to the first multiplexer 421 and the second primitive data y₂ to the multiplier 430. The multiplier then calculates the product of y₂ and z₃, and its result P₁ is obtained at cycle 4. The product P₁ is then stored temporarily at a memory medium, the first register 441. Meanwhile, the computation of P₂=y₃*z₂ starts at cycle 2 in the same manner and obtains the result P₂ at cycle 5. The result is then sent to the second multiplexer 422. After obtaining the values of P₁ and P₂ at the fifth cycle, the computation P₁−P₂, denoted by S₅, can then be commenced and the result is output to a multiplexer, the first and second multiplexer 421 and 422. The rest can be explained by analogy. TABLE 2 is the detailed operation process that is induced from the FIG. 4 and TABLE 1.

Let S₅, S₇, and S₉ denote the common terms: ${\begin{matrix} y_{2} & z_{2} \\ y_{3} & z_{3} \end{matrix}},{\begin{matrix} z_{2} & x_{3} \\ z_{3} & x_{3} \end{matrix}}$

and ${\begin{matrix} x_{2} & y_{2} \\ x_{3} & y_{3} \end{matrix}}.$

Take the calculation for S₅ as an example: $\begin{matrix} {S_{5} = \left| \quad \begin{matrix} y_{2} & z_{2} \\ y_{3} & z_{3} \end{matrix} \right|} \\ {= {{y_{2}z_{3}} - {z_{2}y_{3}}}} \\ {= {P_{1} - P_{2}}} \end{matrix}$

In accordance with FIG. 4 and TABLE 1, the value of P₁ is available at cycle 4 and is stored in the first register 441 and the value of P₂ is obtained at cycle 5 and output to the second multiplexer 422. The subtraction of P₂ from P₁ starts at cycle 5 and the result S₅ is obtained at cycle 8. Likewise, the calculations for S₇ and S₉ start at cycle 7 and 9, and the results are obtained at cycle 10 and 12 respectively.

After obtaining the results for S₅, S₇, and S₉, the system then begins the computation of (x₁*S₅) at cycle 8, (y₁*S₇) at cycle 10, and (z₁*S₉) at cycle 12. The culling test for Δ₁₂₃ is the sum of these 3 terms, denoted by P₈, P₁₀ and P₁₂. The final outcome for Δ₁₂₃ is then obtained at cycle 19. The test outcome for triangle Δ₂₄₃ is obtained at cycle 20 in the same manner.

The controller 410 controls the whole process. It may be pre-installed in the read only memory to control the flow of data and the data selection of the three multiplexers 421, 422, and 423.

At the present time, the culling tests for any planes on a 3-dimensional object are computed individually. It takes 35 cycles to complete culling tests for two different planes of a 3-dimensional object. However, according to this invention, the total time required for two culling tests is 20 cycles. If more calculation devices are provided, for example, more multipliers or adders/subtractors, the total calculation time can be further reduced. For example, if two multipliers and one adder/subtractor are provided, the outcomes of two culling tests can be obtained at cycle 18. The detailed computation procedures are shown in TABLE 3.

While the present invention has been shown and described with reference to a preferred embodiment thereof, and in terms of the illustrative drawings and algorithmic tables, it should not be considered as limited thereby. Various possible modifications, omissions, and alterations could be conceived of by one skilled in the art to the form and the content of any particular embodiment, without departing from the scope of the present invention.

TABLE 1 T Multiplier Adder/Subtractor 1.  P₁ = y₂ * z₃ 2.  P₂ = y₃ * z₂ 3.  P₃ = z₂ * x₃ 4.  P₄ = z₃ * x₂ 5.  P₅ = x₂ * y₃  S₅ = P₁ − P₂ 6.  P₆ = x₃ * y₂ 7.  S₇ = P₃ − P₄ 8.  P₈ = x₁ * S₅ 9.  P₉ = x₄ * S₅  S₉ = P₅ − P₆ 10. P₁₀ = y₁ * S₇ 11. P₁₁ = y₄ * S₇ 12. P₁₂ = z₁ * S₉ 13. P₁₃ = z₄ * S₉ S₁₃ = P₈ + P₁₀ 14. S₁₄ = P₉ + P₁₁ 15. 16. Δ₁₂₃ = P₁₂ + S₁₃ 17. Δ₄₂₃ = P₁₃ + S₁₄ 18. 19. 20.

TABLE 2 Input 2 Mulitplier Output 3^(rd) 2^(nd) T Input 1 1^(st) Multiplexer (x) (x) 1^(st) Reg. 2^(nd) Reg. Multiplexer Multiplexer +/− Output (+/−) 1. y₂ z₃ : — P₁ = y₂ * z₃ 2. y₃ z₃ : — P₂ = y₃ * z₂ 3. y₂ x₃ : — P₃ = z₂ * x₃ 4. z₃ x₃ : — P₄ = z₃ * x₂ P₁ P₁ 5. x₂ y₃ : — P₅ = x₂ * y₃ P₂ P₁ P₁ : — P₂ : — S₅ = P₁ − P₂ 6. x₃ y₂ : — P₆ = x₃ * y₂ P₃ P₃ — : — 7. P₄ P₃ P₃ : — P₄ : — S₇ = P₃ − P₄ 8. x₁ — : S₅ P₈ = x₁ * S₅ P₅ P₅ — : S₅ S₅ 9. x₄ — : S₅ P₉ = x₄ * S₅ P₆ P₅ P₅ : — P₆ : — S₉ = P₅ − P₆ 10. y₁ — : S₇ P₁₀ = y₁ * S₇ P₆ : S₇ S₇ 11. y₄ — : S₇ P₁₁ = y₄ * S₇ P₈ P₈ P₆ : — 12. S₇ : S₉ P₁₂ = z₁ * S₉ P₉ P₈ P₉ — : S₉ 13. S₇ : S₉ P₁₃ = z₄ * S₉ P₁₀ P₈ P₉ P_(d) : — — : P₁₀ S₁₃ = P₈ + P₁₀ 14. S₇ : S₉ P₁₁ P₁₁ P₉ — : P₉ P₁₁ : — S₁₄ = P₉ + P₁₁ 15. S₇ : S₉ P₁₂ P₁₂ — : P₁₀ 16. S₁₃ : S₉ P₁₃ P₁₃ P₁₂ : — —: S₁₃ Δ₁₂₃ = P₁₂ + S₁₃ S₁₃ 17. S₁₃ : S₁₄ P₁₃ P₁₃ : — —: S₁₄ Δ₄₂₃ = P₁₃ + S₁₄ S₁₄ 18. 19. Δ₁₂₃ 20. Δ₄₂₃

TABLE 3 T Multiplier 1 Multiplier 2 +/− 1.  P₁ = y₂ * z₃  P₂ = y₃ * z₂ 2.  P₃ = z₂ * x₃  P₄ = z₃ * x₂ 3.  P₅ = x₂ * y₃  P₆ = x₃ * y₂ 4.  S₅ = P₁ − P₂ 5.  S₇ = P₃ − P₄ 6.  S₉ = P₅ − P₆ 7.  P₈ = x₁ * S₅  P₉ = x₄ * S₅ 8. P₁₀ = y₁ * S₇ P₁₁ = y₄ * S₇ 9. P₁₂ = z₁ * S₉ P₁₃ = z₄ * S₉ 10. 11. S₁₃ = P₈ + P₁₀ 12. S₁₄ = P₉ + P₁₁ 13. 14. Δ₁₂₃ = P₁₂ + S₁₃ 15. Δ₄₂₃ = P₁₃ + S₁₄ 16. 17. 18. 

What is claimed is:
 1. A culling method, used in a computer graphics system, for determining the visibility of two planes at the same time, comprising the steps of: selecting 4 points from the surface of the 3-dimensional object to form two triangles, Δ₁₂₃ and Δ₄₂₃, sharing one adjacent side and two common vertices; determining the coordinates of the selected four vertices for the two triangles sharing vertices V₂ and V₃: assigning three vertices V₁(x₁, y₁, z₁), V₂(x₂, y₂, z₂), and V₃(x₃, y₃, z₃) for the first triangle Δ₁₂₃; assigning three vertices V₄(x₄, y₄, z₄), V₂(x₂, y₂, z₂), and V₃(x₃, y₃, z₃) for the second triangle Δ₄₂₃; computing the three common terms (y₂z₃−z₂y₃), (z₂x₃−x₂z₃), and (x₂y₃−y₂x₃); computing the culling equations x₁(y₂z₃−z₂y₃)+y₁(z₂x₃−x₂z₃)+z₁(x₂y₃−y₂x₃) and x₄(y₂z₃−z₂y₃)+y₄(z₂x₃−x₂z₃)+z₄(x₂y₃−y₂x₃) for Δ₁₂₃ and Δ₄₂₃, respectively; and determining the visibility of the two triangles according to the signs of the two culling equation: if Δ>0, the plane tested being visible; if Δ≦0, the plane tested being invisible.
 2. A culling apparatus for use in a graphics computer to determine the visibility of the two triangles, comprising: a first multiplexer with a first input terminal and a second input terminal, the first input terminal receiving a first primitive data from the system; a multiplier with a first input terminal and a second input terminal, the first input terminal receiving a second primitive data from the system and the second input terminal receiving the output signal of said first multiplexer; a first register for storing data received from said multiplier; a second register for storing data received from said multiplier; a second multiplexer with a first input terminal and a second input terminal, the first input terminal receiving signals from the multiplier; a third multiplexer with two input terminals for receiving signals from said first and second registers; an adder for adding the data from said second multiplexer and said third multiplexer and output a data; a controller installed in ROM with a set of instruction commands to be used in the computer graphic systems to compute and control all input and output data for the culling test, wherein the second input terminal of said first multiplexer receiving the output data from said adder, the second input terminal of said second multiplexer receiving the output data from said adder, and if the final output data of said adder being greater than zero, the plane tested is visible, otherwise, the plane tested is invisible.
 3. The culling apparatus of claim 2, wherein the multiplier and adder are with pipeline structures. 